package com.ssy.lingxi.member.merchant.controller.web;

import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.member.merchant.model.vo.platform.request.PlatformMenuIdVO;
import com.ssy.lingxi.member.merchant.model.vo.platform.request.PlatformMenuUpdateVO;
import com.ssy.lingxi.member.merchant.model.vo.platform.request.PlatformMenuVO;
import com.ssy.lingxi.member.merchant.model.vo.platform.response.PlatformMenuDetailVO;
import com.ssy.lingxi.member.merchant.model.vo.platform.response.PlatformMenuTreeVO;
import com.ssy.lingxi.member.merchant.service.web.IPlatformMenuService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu 平台后台 - 菜单管理相关接口
 * @author 万宁
 * @version 2.0.0
 * @date 2022-04-13
 */
@RestController
@RequestMapping("/member/platform/menu")
public class PlatformMenuController {
    @Resource
    private IPlatformMenuService platformMenuService;

    /**
     * 查询树形菜单列表
     * @param headers Http头部信息
     * @return 查询结果
     */
    @RequestMapping(value = "/tree", method = RequestMethod.GET)
    public Wrapper<List<PlatformMenuTreeVO>> treeMenus(@RequestHeader HttpHeaders headers) {
        return platformMenuService.treeMenus(headers);
    }

    /**
     * 查询菜单详情
     * @param headers Http头部信息
     * @param idVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/find", method = RequestMethod.GET)
    public Wrapper<PlatformMenuDetailVO> findMenu(@RequestHeader HttpHeaders headers, @Valid PlatformMenuIdVO idVO) {
        return platformMenuService.findMenu(headers, idVO);
    }

    /**
     * 新增菜单
     * @param headers Http头部信息
     * @param menuVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public Wrapper<Void> addMenu(@RequestHeader HttpHeaders headers, @RequestBody @Valid PlatformMenuVO menuVO) {
        return platformMenuService.addMenu(headers, menuVO);
    }

    /**
     * 修改菜单
     * @param headers Http头部信息
     * @param updateVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Wrapper<Void> updateMenu(@RequestHeader HttpHeaders headers, @RequestBody @Valid PlatformMenuUpdateVO updateVO) {
        return platformMenuService.updateMenu(headers, updateVO);
    }

    /**
     * 删除菜单
     * @param headers Http头部信息
     * @param idVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public Wrapper<Void> deleteMenu(@RequestHeader HttpHeaders headers, @RequestBody @Valid PlatformMenuIdVO idVO) {
        return platformMenuService.deleteMenu(headers, idVO);
    }
}
